package day11;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Locale;
import java.util.Scanner;

/**
 * @author Xiao
 * @date 2021/7/31
 */
public class Test04 {
    /**
     * 4. 键盘录入一个字符串，输入身份证号码，将其中的偶数写到当前模块的code.txt文件中
     */
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        String id;
        while (true) {
            System.out.println("请输入一个身份证号码(18位)：");
            id = sc.nextLine();
            if (id.length() == 18) {
                break;
            }
        }
        FileOutputStream fos = new FileOutputStream("homework\\sr\\day11\\code.txt");
        byte[] bytes = id.getBytes();
        for (byte b : bytes) {
            int i = b;

            if (i >= '0' && i <= '9' && i % 2 == 0) {
               fos.write(i);
            }
        }
        fos.close();
    }
}
